
#include "frame_controller.h"

std::once_flag FrameController::_once;
std::unique_ptr<FrameController> FrameController::_instance;

FrameController& FrameController::getInstance()
{
    std::call_once(FrameController::_once, []() { _instance.reset(new FrameController()); });
    return *_instance;
}

void FrameController::updateFrameReq()
{
    // dummy
    _scheme = PinScheme("1111111111");
}

int FrameController::getPinsCount()
{
    // dummy
    return _scheme.getMarkedCount();
}

connection_t FrameController::onTurn(Action<PinScheme>::slot_t callback)
{
    return _onTurn.connect(callback);
}

void FrameController::simulateTurn(const std::string& scheme)
{
    //_scheme = PinScheme("1111111111");
    
    
    
    _scheme.uncheckPins(scheme);
    
    _scheme.print();    
    //std::cout << "get maeked scheme count " << _scheme.getMarkedCount() << std::endl;
    _onTurn(_scheme);
}